How to print Decimal number without trailing 0s in dxl

Hello All,

How to achieve below program in DXL

#include <stdio.h>  //ignore
int main() {  //ignore
 
float f1 = 12;
  float f2 = 12.1;
  float f3 = 12.12;
  float f4 = 12.1234;
  printf("%g\n", f1);
  printf("%g\n", f2);
  printf("%g\n", f3);
  printf("%g\n", f4);
  return 0;
}

Result:

12
12.1
12.12
12.1234

Please help me.

 

Thanks in Advance

 

 


DOORSDXL - Mon Aug 29 10:53:36 EDT 2016

Re: How to print Decimal number without trailing 0s in dxl
DOORSHAM - Mon Aug 29 13:03:34 EDT 2016

Assign the real to an int.

 

Re: How to print Decimal number without trailing 0s in dxl
DOORSDXL - Mon Aug 29 21:34:59 EDT 2016

DOORSHAM - Mon Aug 29 13:03:34 EDT 2016

Assign the real to an int.

 

Hello,

Thanks for your reply.

I tried the as per your suggestion.

real r =1.2
int i = intOf r

print i

 

//Output is 1 not 1.2

//Am looking for 1.2 without trailing 0s

Hope to hear from you.

 

Thanks in Advance

 

 

Re: How to print Decimal number without trailing 0s in dxl
DOORSHAM - Mon Aug 29 21:54:51 EDT 2016

DOORSDXL - Mon Aug 29 21:34:59 EDT 2016

Hello,

Thanks for your reply.

I tried the as per your suggestion.

real r =1.2
int i = intOf r

print i

 

//Output is 1 not 1.2

//Am looking for 1.2 without trailing 0s

Hope to hear from you.

 

Thanks in Advance

 

 

My misunderstanding.

 

Convert to a string then chop the string.

Re: How to print Decimal number without trailing 0s in dxl
DOORSDXL - Mon Aug 29 22:29:38 EDT 2016

DOORSHAM - Mon Aug 29 21:54:51 EDT 2016

My misunderstanding.

 

Convert to a string then chop the string.

Hello Thanks,

This problem occurred when i try to get all the baselines greater than  0.9 for example.

In the above case  i am taking all the major and minor baselines as real and comparing with 0.9.

Suppose i have baselines like 0.1 , 0.2, 0.3 ........ 0.9, 0.10, 0.11, 0,12 

if i compare 0.9 > 0.10 it says 0.9 is greater

if i compare 0.9 > 0.11 it says 0.9 is greater

but in our baseline sequence 0.10 & 0.11  is greater than 0.9. Actually this is issue.

Please let me know if have any other idea to get all the baseline greater than specific baseline.

Can i compare with the baseline created date? is it a good idea ? Please clarify.  thanks in advance

Hope to hear from you.

 

 

 

Re: How to print Decimal number without trailing 0s in dxl
Mike.Scharnow - Tue Aug 30 02:21:15 EDT 2016

DOORSDXL - Mon Aug 29 22:29:38 EDT 2016

Hello Thanks,

This problem occurred when i try to get all the baselines greater than  0.9 for example.

In the above case  i am taking all the major and minor baselines as real and comparing with 0.9.

Suppose i have baselines like 0.1 , 0.2, 0.3 ........ 0.9, 0.10, 0.11, 0,12 

if i compare 0.9 > 0.10 it says 0.9 is greater

if i compare 0.9 > 0.11 it says 0.9 is greater

but in our baseline sequence 0.10 & 0.11  is greater than 0.9. Actually this is issue.

Please let me know if have any other idea to get all the baseline greater than specific baseline.

Can i compare with the baseline created date? is it a good idea ? Please clarify.  thanks in advance

Hope to hear from you.

 

 

 

You should compare by baseline creation date.

Remember that you have the possibility to give suffixes to a baseline.

Which one is the greatest: "0.9", "0.9 alpha", "0.9 final", "0.9 2nd attempt"?

With "dateTimeOf b" you get a comparable value of baseline b.

 

If you are sure that you do not have suffixes and if you are sure that you do not have more than 10.00 baselines for a module, you could calculate like this

(major b) * 10000 + (minor b)

and use the result for comparison

Re: How to print Decimal number without trailing 0s in dxl
DOORSDXL - Tue Aug 30 04:22:57 EDT 2016

Mike.Scharnow - Tue Aug 30 02:21:15 EDT 2016

You should compare by baseline creation date.

Remember that you have the possibility to give suffixes to a baseline.

Which one is the greatest: "0.9", "0.9 alpha", "0.9 final", "0.9 2nd attempt"?

With "dateTimeOf b" you get a comparable value of baseline b.

 

If you are sure that you do not have suffixes and if you are sure that you do not have more than 10.00 baselines for a module, you could calculate like this

(major b) * 10000 + (minor b)

and use the result for comparison

Thanks All, Your inputs are helped.

Re: How to print Decimal number without trailing 0s in dxl
strathglass - Sat Sep 17 14:31:05 EDT 2016

Mike.Scharnow - Tue Aug 30 02:21:15 EDT 2016

You should compare by baseline creation date.

Remember that you have the possibility to give suffixes to a baseline.

Which one is the greatest: "0.9", "0.9 alpha", "0.9 final", "0.9 2nd attempt"?

With "dateTimeOf b" you get a comparable value of baseline b.

 

If you are sure that you do not have suffixes and if you are sure that you do not have more than 10.00 baselines for a module, you could calculate like this

(major b) * 10000 + (minor b)

and use the result for comparison

Actually, using baseline date is not really a good solution: those are pure dates only, no time. So if you have multiple baselines on the same date, you can still have the order get messed up during any kind of sort.

What I have done is just use the order returned by DOORS when you get all the baseline sets in a baseline set definition: for bs in bsd do {put(bsList,bsSize++,bs)}

That seems to always be in chronological order. Of course I can't guarantee it will always work that way!

Re: How to print Decimal number without trailing 0s in dxl
Mike.Scharnow - Mon Sep 19 06:50:42 EDT 2016

strathglass - Sat Sep 17 14:31:05 EDT 2016

Actually, using baseline date is not really a good solution: those are pure dates only, no time. So if you have multiple baselines on the same date, you can still have the order get messed up during any kind of sort.

What I have done is just use the order returned by DOORS when you get all the baseline sets in a baseline set definition: for bs in bsd do {put(bsList,bsSize++,bs)}

That seems to always be in chronological order. Of course I can't guarantee it will always work that way!

hm, cannot confirm this with 9.6.1.6, at least not if you use dateTimeOf. But your solution should work, too.

Baseline b
  for b in current Module do {
  print major b " - " minor b " - " suffix b " - " dateTimeOf b "\n"
}
0 - 0 - a - 09/19/16 12:45:55
0 - 0 - 0  a - 09/19/16 12:46:13
0 - 0 - 0 - 09/19/16 12:46:26
0 - 0 -  - 09/19/16 12:46:33

 

Re: How to print Decimal number without trailing 0s in dxl
strathglass - Mon Sep 19 08:21:09 EDT 2016

Mike.Scharnow - Mon Sep 19 06:50:42 EDT 2016

hm, cannot confirm this with 9.6.1.6, at least not if you use dateTimeOf. But your solution should work, too.

Baseline b
  for b in current Module do {
  print major b " - " minor b " - " suffix b " - " dateTimeOf b "\n"
}
0 - 0 - a - 09/19/16 12:45:55
0 - 0 - 0  a - 09/19/16 12:46:13
0 - 0 - 0 - 09/19/16 12:46:26
0 - 0 -  - 09/19/16 12:46:33

 

Yes, the well documented dateTimeOf b ... oh wait, no: the DXL manual only indicates the "Date dateOf(Baseline b)" function.

Frustating when the documentation lets you down. Yes, if dateTimeOf works, I would use that and it should resolve the issue!

Re: How to print Decimal number without trailing 0s in dxl
Mike.Scharnow - Mon Sep 19 08:25:22 EDT 2016

strathglass - Mon Sep 19 08:21:09 EDT 2016

Yes, the well documented dateTimeOf b ... oh wait, no: the DXL manual only indicates the "Date dateOf(Baseline b)" function.

Frustating when the documentation lets you down. Yes, if dateTimeOf works, I would use that and it should resolve the issue!

I think the  latest  version of Mathias' Perms list is available at https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014580797

Re: How to print Decimal number without trailing 0s in dxl
strathglass - Mon Sep 19 08:26:08 EDT 2016

By the way, do you really have to restrict this to a for loop "for baseline in module" loop? Seems limiting, and seems odd it wouldn't work on a baseline (e.g.saved into a skip list to be processed later).

Re: How to print Decimal number without trailing 0s in dxl
Mike.Scharnow - Mon Sep 19 08:41:44 EDT 2016

strathglass - Mon Sep 19 08:26:08 EDT 2016

By the way, do you really have to restrict this to a for loop "for baseline in module" loop? Seems limiting, and seems odd it wouldn't work on a baseline (e.g.saved into a skip list to be processed later).

Well, I did not find a direct access perm like 

Baseline baseline (Module m, int major, minor, string suffix)

Besides the for b in m loop, I think the only other thing is 

    Baseline getMostRecentBaseline (Module, [bool])

But of course, once you retrieved the baselines from the for loop, you can store them in a skip list for later use